package com.booksea.parser

import java.net.URLEncoder
import com.booksea.xml.NekoHTMLFactoryAdapter
import xml.Text._
import xml.Text

/**
 * Created by IntelliJ IDEA.
 * User: Sufeng
 * Date: 12-9-1
 * Time: 上午10:52
 * To change this template use File | Settings | File Templates.
 */

object JingDongParser {
  val surl = "http://search.360buy.com/Search?keyword=java&enc=utf-8&book=y"

  def search(keyword: String): Set[String] = {
    var ret = Set[String]()
    var url = "http://search.360buy.com/Search?keyword=" + URLEncoder.encode(keyword, "utf8") + "&enc=utf-8&book=y"
    var node = new NekoHTMLFactoryAdapter load url
    (node \\ "DT" filter (_ \ "@class" contains Text("p-name"))) foreach (node => ret + ((node \ "A" text) trim()))
    ret
  }

}
